<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Struct process_environment</title>
<link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset">
<link rel="up" href="../../../boost_process/v2.html#header.boost.process.v2.environment_hpp" title="Header &lt;boost/process/v2/environment.hpp&gt;">
<link rel="prev" href="environment/unset_idm8291.html" title="Function unset">
<link rel="next" href="../../../std/hash_boost_process_idm8331.html" title="Struct hash&lt;boost::process::v2::environment::key&gt;">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr>
<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td>
<td align="center"><a href="../../../../../index.html">Home</a></td>
<td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td>
<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td>
<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td>
<td align="center"><a href="../../../../../more/index.htm">More</a></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="environment/unset_idm8291.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../boost_process/v2.html#header.boost.process.v2.environment_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../../std/hash_boost_process_idm8331.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.process.v2.process_environment"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Struct process_environment</span></h2>
<p>boost::process::v2::process_environment — Initializer for the environment of sub process. </p>
</div>
<h2 class="refsynopsisdiv-title">Synopsis</h2>
<div class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../boost_process/v2.html#header.boost.process.v2.environment_hpp" title="Header &lt;boost/process/v2/environment.hpp&gt;">boost/process/v2/environment.hpp</a>&gt;

</span>
<span class="keyword">struct</span> <a class="link" href="process_environment.html" title="Struct process_environment">process_environment</a> <span class="special">{</span>
  <span class="comment">// <a class="link" href="process_environment.html#boost.process.v2.process_environmentconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="process_environment.html#idm6967-bb"><span class="identifier">process_environment</span></a><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">initializer_list</span><span class="special">&lt;</span> <span class="identifier">string_view</span> <span class="special">&gt;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Args<span class="special">&gt;</span> <a class="link" href="process_environment.html#idm6970-bb"><span class="identifier">process_environment</span></a><span class="special">(</span><span class="identifier">Args</span> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="process_environment.html#idm6933-bb">public static functions</a></span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Args<span class="special">&gt;</span> 
    <span class="keyword">static</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="special">&gt;</span> 
    <a class="link" href="process_environment.html#idm6934-bb"><span class="identifier">build_env</span></a><span class="special">(</span><span class="identifier">Args</span> <span class="special">&amp;&amp;</span><span class="special">,</span> 
              <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">enable_if</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">is_convertible</span><span class="special">&lt;</span> <span class="keyword">decltype</span><span class="special">(</span><span class="special">*</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special">&lt;</span> <span class="identifier">Args</span> <span class="special">&gt;</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">)</span><span class="special">,</span> <a class="link" href="../../../boost_process/v2.html#boost.process.v2.cstring_ref">cstring_ref</a> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">value</span><span class="special">,</span> 
              <span class="special">::</span><span class="identifier">type</span> <span class="special">*</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="process_environment.html#idm6946-bb">public member functions</a></span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Args<span class="special">&gt;</span> 
    <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="special">&gt;</span> 
    <a class="link" href="process_environment.html#idm6947-bb"><span class="identifier">build_env</span></a><span class="special">(</span><span class="identifier">Args</span> <span class="special">&amp;&amp;</span><span class="special">,</span> 
              <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">enable_if</span><span class="special">&lt;</span> <span class="special">!</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">is_convertible</span><span class="special">&lt;</span> <span class="keyword">decltype</span><span class="special">(</span><span class="special">*</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special">&lt;</span> <span class="identifier">Args</span> <span class="special">&gt;</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">)</span><span class="special">,</span> <a class="link" href="../../../boost_process/v2.html#boost.process.v2.cstring_ref">cstring_ref</a> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">value</span><span class="special">,</span> 
              <span class="special">::</span><span class="identifier">type</span> <span class="special">*</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">error_code</span> <a class="link" href="process_environment.html#idm6959-bb"><span class="identifier">on_setup</span></a><span class="special">(</span><span class="identifier">posix</span><span class="special">::</span><span class="identifier">default_launcher</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="identifier">filesystem</span><span class="special">::</span><span class="identifier">path</span> <span class="special">&amp;</span><span class="special">,</span> 
                      <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="keyword">const</span> <span class="special">*</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// public data members</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <a class="link" href="environment/key_value_pair.html" title="Struct key_value_pair">environment::key_value_pair</a> <span class="special">&gt;</span> <span class="identifier">env_buffer</span><span class="special">;</span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="special">&gt;</span> <span class="identifier">env</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="id-1.3.29.12.8.5.19.4"></a><h2>Description</h2>
<p>This will set the environment in a subprocess:</p>
<pre class="programlisting"><span class="identifier">process</span> <span class="identifier">proc</span><span class="special">{</span><span class="identifier">executor</span><span class="special">,</span> <span class="identifier">find_executable</span><span class="special">(</span><span class="string">"printenv"</span><span class="special">)</span><span class="special">,</span> <span class="special">{</span><span class="string">"foo"</span><span class="special">}</span><span class="special">,</span> <span class="identifier">process_environment</span><span class="special">{</span><span class="string">"foo=bar"</span><span class="special">}</span><span class="special">}</span><span class="special">;</span>
</pre>
<p>The environment initializer will persist it's state, so that it can be used multiple times. Do however note the the Operating System is allowed to modify the internal state.</p>
<pre class="programlisting"><span class="keyword">auto</span> <span class="identifier">exe</span> <span class="special">=</span> <span class="identifier">find_executable</span><span class="special">(</span><span class="string">"printenv"</span><span class="special">)</span><span class="special">;</span>
<span class="identifier">process_environment</span> <span class="identifier">env</span> <span class="special">=</span> <span class="special">{</span><span class="string">"FOO=BAR"</span><span class="special">,</span> <span class="string">"BAR=FOO"</span><span class="special">}</span><span class="special">;</span>

<span class="identifier">process</span> <span class="identifier">proc1</span><span class="special">(</span><span class="identifier">executor</span><span class="special">,</span> <span class="identifier">exe</span><span class="special">,</span> <span class="special">{</span><span class="string">"FOO"</span><span class="special">}</span><span class="special">,</span> <span class="identifier">env</span><span class="special">)</span><span class="special">;</span>
<span class="identifier">process</span> <span class="identifier">proc2</span><span class="special">(</span><span class="identifier">executor</span><span class="special">,</span> <span class="identifier">exe</span><span class="special">,</span> <span class="special">{</span><span class="string">"BAR"</span><span class="special">}</span><span class="special">,</span> <span class="identifier">env</span><span class="special">)</span><span class="special">;</span>
</pre>
<p> </p>
<div class="refsect2">
<a name="id-1.3.29.12.8.5.19.4.6"></a><h3>
<a name="boost.process.v2.process_environmentconstruct-copy-destruct"></a><code class="computeroutput">process_environment</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><pre class="literallayout"><a name="idm6967-bb"></a><span class="identifier">process_environment</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">initializer_list</span><span class="special">&lt;</span> <span class="identifier">string_view</span> <span class="special">&gt;</span> sv<span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Args<span class="special">&gt;</span> <a name="idm6970-bb"></a><span class="identifier">process_environment</span><span class="special">(</span><span class="identifier">Args</span> <span class="special">&amp;&amp;</span> args<span class="special">)</span><span class="special">;</span></pre></li>
</ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.29.12.8.5.19.4.7"></a><h3>
<a name="idm6933-bb"></a><code class="computeroutput">process_environment</code> public static functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Args<span class="special">&gt;</span> 
  <span class="keyword">static</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="special">&gt;</span> 
  <a name="idm6934-bb"></a><span class="identifier">build_env</span><span class="special">(</span><span class="identifier">Args</span> <span class="special">&amp;&amp;</span> args<span class="special">,</span> 
            <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">enable_if</span><span class="special">&lt;</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">is_convertible</span><span class="special">&lt;</span> <span class="keyword">decltype</span><span class="special">(</span><span class="special">*</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special">&lt;</span> <span class="identifier">Args</span> <span class="special">&gt;</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">)</span><span class="special">,</span> <a class="link" href="../../../boost_process/v2.html#boost.process.v2.cstring_ref">cstring_ref</a> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">value</span><span class="special">,</span> 
            <span class="special">::</span><span class="identifier">type</span> <span class="special">*</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">)</span><span class="special">;</span></pre></li></ol></div>
</div>
<div class="refsect2">
<a name="id-1.3.29.12.8.5.19.4.8"></a><h3>
<a name="idm6946-bb"></a><code class="computeroutput">process_environment</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem"><pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> Args<span class="special">&gt;</span> 
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">vector</span><span class="special">&lt;</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span> <span class="special">&gt;</span> 
  <a name="idm6947-bb"></a><span class="identifier">build_env</span><span class="special">(</span><span class="identifier">Args</span> <span class="special">&amp;&amp;</span> args<span class="special">,</span> 
            <span class="keyword">typename</span> <span class="identifier">std</span><span class="special">::</span><span class="identifier">enable_if</span><span class="special">&lt;</span> <span class="special">!</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">is_convertible</span><span class="special">&lt;</span> <span class="keyword">decltype</span><span class="special">(</span><span class="special">*</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">begin</span><span class="special">(</span><span class="identifier">std</span><span class="special">::</span><span class="identifier">declval</span><span class="special">&lt;</span> <span class="identifier">Args</span> <span class="special">&gt;</span><span class="special">(</span><span class="special">)</span><span class="special">)</span><span class="special">)</span><span class="special">,</span> <a class="link" href="../../../boost_process/v2.html#boost.process.v2.cstring_ref">cstring_ref</a> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">value</span><span class="special">,</span> 
            <span class="special">::</span><span class="identifier">type</span> <span class="special">*</span> <span class="special">=</span> <span class="keyword">nullptr</span><span class="special">)</span><span class="special">;</span></pre></li>
<li class="listitem"><pre class="literallayout"><span class="identifier">error_code</span> <a name="idm6959-bb"></a><span class="identifier">on_setup</span><span class="special">(</span><span class="identifier">posix</span><span class="special">::</span><span class="identifier">default_launcher</span> <span class="special">&amp;</span> launcher<span class="special">,</span> 
                    <span class="keyword">const</span> <span class="identifier">filesystem</span><span class="special">::</span><span class="identifier">path</span> <span class="special">&amp;</span><span class="special">,</span> <span class="keyword">const</span> <span class="keyword">char</span> <span class="special">*</span><span class="keyword">const</span> <span class="special">*</span><span class="special">)</span><span class="special">;</span></pre></li>
</ol></div>
</div>
</div>
</div>
<div class="copyright-footer">Copyright © 2006-2012 Julio M. Merino Vidal, Ilya Sokolov,
      Felipe Tanus, Jeff Flinn, Boris Schaeling<br>Copyright © 2016 Klemens D. Morgenstern<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
      </p>
</div>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="environment/unset_idm8291.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../boost_process/v2.html#header.boost.process.v2.environment_hpp"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="../../../std/hash_boost_process_idm8331.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
